Skip to content

fix: add mandatory SHA-256 checksum verification to install.sh#226

Open
vinayada1 wants to merge 3 commits intoprivateerproj:mainfrom
vinayada1:fix/installer-checksum-verification
Open

fix: add mandatory SHA-256 checksum verification to install.sh#226
vinayada1 wants to merge 3 commits intoprivateerproj:mainfrom
vinayada1:fix/installer-checksum-verification

Conversation

@vinayada1
Copy link
Copy Markdown
Contributor

Summary

install.sh previously downloaded the release archive and piped it directly into tar with no integrity verification. A supply-chain compromise, swapped release asset, or MITM could deliver a tampered binary without any indication. This change makes verification mandatory and fail-closed:

  • The archive is downloaded to a temp directory before extraction
  • The GoReleaser checksums.txt asset is fetched from the same release
  • SHA-256 is verified before any extraction; failure, missing asset, or digest mismatch all abort the install
  • Release asset URL parsing is replaced with a structured extract_download_urls / find_release_asset_url helper that works on both compact and multiline GitHub API JSON, replacing the previous fragile grep|cut approach
  • BASH_SOURCE guard added so the script can be safely sourced in tests without triggering installation

Breaking changes

install.sh will now refuse to install if a release does not include a checksums.txt asset. All published releases using GoReleaser include this file by default. Pre-GoReleaser releases without the asset will no longer install via this script.

The installer previously piped the downloaded archive directly into tar
without any integrity check, allowing a compromised release asset or
MITM to silently deliver a tampered binary.

Changes:
- Download the release archive to a temp file before extraction
- Fetch the GoReleaser checksums.txt asset from the same release
- Verify SHA-256 of the archive against the checksums file before
  extracting; abort on mismatch, missing asset, or download failure
  (fail-closed — no fallback to unverified install)
- Extract asset URLs with a structured parser (extract_download_urls /
  find_release_asset_url) that works on both compact and multiline
  GitHub API JSON, replacing brittle grep|cut scraping
- Guard main() behind BASH_SOURCE so the script can be safely sourced
  in tests without triggering installation
- Wire installer tests into make test via Makefile
- Add .PHONY declarations to prevent make skipping targets when a
  directory named 'test' exists

Tests added (test/install_test.sh):
- Happy path with multiline JSON response
- Happy path with compact single-line JSON response
- Fail when checksums asset is absent from release
- Fail when checksums file download errors
- Fail when SHA-256 digest mismatches
Copilot AI review requested due to automatic review settings April 7, 2026 17:26
@vinayada1 vinayada1 requested a review from a team as a code owner April 7, 2026 17:26
@github-actions github-actions bot added the fix label Apr 7, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the install.sh installer by making release downloads verify a mandatory SHA-256 checksum before extracting and installing the pvtr binary, reducing supply-chain risk for end users.

Changes:

  • Download release archive to a temp directory, fetch checksums.txt, and verify SHA-256 before extraction.
  • Replace fragile URL parsing with extract_download_urls / find_release_asset_url helpers that work across compact/multiline GitHub API JSON.
  • Add a dedicated Bash test (test/install_test.sh) and run it as part of make test; add a BASH_SOURCE guard so install.sh can be sourced in tests.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
install.sh Adds checksum enforcement and new release-asset URL extraction helpers; makes script safe to source in tests.
test/install_test.sh Adds mocked integration-style tests covering checksum success/failure and JSON parsing formats.
Makefile Runs the new installer test during the test target and declares phony targets.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

jmeridth added a commit that referenced this pull request Apr 8, 2026
## What

Extracted the integration test job from ci.yml into a dedicated
integration.yml workflow and replaced octo-sts OIDC token exchange with
the default GITHUB_TOKEN in both integration.yml and
osps-security-assessment.yml. Deleted the STS policy file.

## Why

Both workflows only perform read-only operations on public repos. The
default GITHUB_TOKEN is sufficient and available to fork PRs under the
pull_request event, eliminating the OIDC minting that caused fork PR
failures (e.g. PRs #226, #227).

## Notes

- Deleted .github/chainguard/privateer.sts.yaml since no workflow in this repo uses octo-sts anymore
- The release.yml workflow still uses octo-sts for homebrew-tap access, but its STS policy lives in that repo
- Removed id-token:write from both workflows, reducing privilege scope
- Added explicit permissions: contents: read to the changes job in integration.yml

Signed-off-by: jmeridth <[email protected]>
jmeridth added a commit that referenced this pull request Apr 8, 2026
## What

Extracted the integration test job from ci.yml into a dedicated
integration.yml workflow and replaced octo-sts OIDC token exchange with
the default GITHUB_TOKEN in both integration.yml and
osps-security-assessment.yml. Deleted the STS policy file.

## Why

Both workflows only perform read-only operations on public repos. The
default GITHUB_TOKEN is sufficient and available to fork PRs under the
pull_request event, eliminating the OIDC minting that caused fork PR
failures (e.g. PRs #226, #227).

## Notes

- Deleted .github/chainguard/privateer.sts.yaml since no workflow in this repo uses octo-sts anymore
- The release.yml workflow still uses octo-sts for homebrew-tap access, but its STS policy lives in that repo
- Removed id-token:write from both workflows, reducing privilege scope
- Added explicit permissions: contents: read to the changes job in integration.yml

Signed-off-by: jmeridth <[email protected]>
@jmeridth
Copy link
Copy Markdown
Member

jmeridth commented Apr 8, 2026

@vinayada1 This change is good if we hadn't started work on #204. If we can finish that work, we can use an actual pvtr command and not bash scripts. I'm willing to approve and merge this for now but that PR needs to be a quick follow.

Can you please respond to the Copilot feedback.

@eddie-knight
Copy link
Copy Markdown
Contributor

Yes, actually my headspace on the other PR installer was primarily focused on plugins — so this is perfect.

Signed-off-by: Vinaya Damle <[email protected]>
@vinayada1 vinayada1 force-pushed the fix/installer-checksum-verification branch from 17ac43c to 7f3149e Compare April 9, 2026 18:15
@vinayada1
Copy link
Copy Markdown
Contributor Author

@vinayada1 This change is good if we hadn't started work on #204. If we can finish that work, we can use an actual pvtr command and not bash scripts. I'm willing to approve and merge this for now but that PR needs to be a quick follow.

Can you please respond to the Copilot feedback.

Addressed the comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants